//
//  ZYCScheduleParentCell.m
//  ZDSC
//
//  Created by ZDTX on 2021/8/12.
//

#import "ZYCScheduleParentCell.h"
#import "ZYCScheduleModel.h"

@interface ZYCScheduleParentCell ()

@property (nonatomic, strong) UILabel *courseNameLabel;
@property (nonatomic, strong) UILabel *courseAddressLabel;
@property (nonatomic, strong) UILabel *courseTeacherLabel;
@property (nonatomic, strong) UILabel *courseStusLabel;
@property (nonatomic, strong) UILabel *line;
@end
@implementation ZYCScheduleParentCell

- (void)setModel:(ZYCScheduleModel *)model{
    _model = model;
    _courseNameLabel.text = model.title;
    _courseAddressLabel.text = [NSString stringWithFormat:@"授课地点:%@",model.courseAddress];
    _courseTeacherLabel.text = [NSString stringWithFormat:@"授课老师:%@",model.teacherName];
    _courseStusLabel.text = [NSString stringWithFormat:@"上课学生:%@",model.studentName];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = HEX_RGB(@"#FAFAFA");
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        [self.contentView addSubview:self.courseNameLabel];
        [self.contentView addSubview:self.courseAddressLabel];
        [self.contentView addSubview:self.courseTeacherLabel];
        [self.contentView addSubview:self.courseStusLabel];
        [self.contentView addSubview:self.line];
        
        [self.courseNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView).offset(15.0f);
            make.left.equalTo(self.contentView).offset(21.0f);
            make.right.equalTo(self.contentView).offset(-21.0f);
        }];
        
        [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.courseNameLabel.mas_bottom).offset(17.0f);
            make.left.equalTo(self.contentView).offset(21.0f);
            make.right.equalTo(self.contentView).offset(-21.0f);
            make.height.mas_equalTo(1.0f);
        }];
        
        [self.courseAddressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(21.0f);
            make.top.equalTo(self.line.mas_bottom).offset(14.0f);
        }];
        
        [self.courseTeacherLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.contentView).offset(-21.0f);
            make.centerY.equalTo(self.courseAddressLabel);
        }];
        
        [self.courseStusLabel mas_makeConstraints:^(MASConstraintMaker *make) {           make.left.equalTo(self.contentView).offset(21.0f);
            make.top.equalTo(self.courseAddressLabel.mas_bottom).offset(14.0f);
        }];

    }
    return self;
}


- (UILabel *)courseNameLabel {
    if (!_courseNameLabel) {
        _courseNameLabel = [UILabel LabelWithFont:kSystemBoldFont(17.0f) titleColor:HEX_RGB(@"#2B302D") textAlignment:ZZTextAlignmentLeft];
        _courseNameLabel.numberOfLines = 1;
    }
    return _courseNameLabel;
}


- (UILabel *)courseAddressLabel {
    if (!_courseAddressLabel) {
        _courseAddressLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Light", 14) titleColor:HEX_RGB(@"#999999") textAlignment:ZZTextAlignmentLeft];
    }
    return _courseAddressLabel;
}

- (UILabel *)courseTeacherLabel {
    if (!_courseTeacherLabel) {
        _courseTeacherLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Light", 14) titleColor:HEX_RGB(@"#999999") textAlignment:ZZTextAlignmentRight];
    }
    return _courseTeacherLabel;
}

- (UILabel *)courseStusLabel {
    if (!_courseStusLabel) {
        _courseStusLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Light", 14) titleColor:HEX_RGB(@"#999999") textAlignment:ZZTextAlignmentLeft];
    }
    return _courseStusLabel;
}



- (UILabel *)line {
    if (!_line) {
        _line = [[UILabel alloc] init];
        _line.backgroundColor = HEX_RGB(@"#EDEDED");
    }
    return _line;
}


@end
